package model;

public class Cavalier extends AbstractPiece {

	public Cavalier(String name, Couleur couleur, Coord coord) {
		super(name, couleur, coord);
	}

	@Override
	public boolean isMoveOk(int xFinal, int yFinal) {
		if(this.isBouger(xFinal, yFinal)){
			//Si on change de 2 cases en X
			if(xFinal == (getX() + 2) || xFinal == (getX() - 2)){
				//Une case en Y
				if(yFinal == (getY() + 1) || yFinal == (getY() - 1)){
					return true;
				}
			}
			//Si on change de 2 cases en Y
			else if(yFinal == (getY() + 2) || yFinal == (getY() - 2)){
				//Une case en X
				if(xFinal == (getX() + 1) || xFinal == (getX() - 1)){
					return true;
				}
			}
		}
		return false;
	}
	
}
